import pymysql
user=input('username :')
pwd=input('password :')
conn=pymysql.connect(host='127.0.0.1',user='root',password='FW249746',database='day42')

cur=conn.cursor(cursor=pymysql.cursors.DictCursor)
sql='select * from userinfo where user= %s and password= %s'
cur.execute(sql,(user,pwd))
print(sql)
print(cur.fetchone())

# pymysql
    # python操作mysql数据库
        # 连接数据库
        # 获取游标
        # 执行sql(增删改查)
        # 如果涉及到修改 : 提交
        # 关闭游标
        # 关闭库
    # sql注入
        # 传参数,注意sql注入的问题,传参数通过execute方法来传
        # execute('select * from 表 where name = %s',('alex',))
# mysql的库/表备份
# 事务
    # 锁


# sql注入
# select * from userinfo where user = "1869" or 1=1;-- " and password = "3714";

# 开启事务
# begin;
# select age from userinfo where id =1 for update; for update 添加行锁
#commit 提交事务





